<template>
  <div>
    <h1>修改XXX积分</h1>
    <hr />
    <el-form
      :model="ruleForm"
      status-icon
      :rules="rules"
      ref="ruleForm"
      label-width="100px"
      class="demo-ruleForm"
    >
      <el-form-item label="剩余积分" prop="points">
        <el-input v-model="ruleForm.points" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm('ruleForm')"
          >发送</el-button
        >
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    var validatePoints = (rule, value, callback) => {
      if (value === "") {
        callback(new Error("请输入积分"));
      }
    };
    return {
      ruleForm: {
        points: "",
      },
      rules: {
        points: [{ validator: validatePoints, trigger: "blur" }],
      },
    };
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert("submit!");
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped>
hr {
  margin: 20px 0;
}

.el-input {
  width: 300px;
}
</style>